package zli.prototype.shallow;

import lombok.Data;

import java.util.List;

/**
 * @Desc
 * @Author Zerlinda
 * @Date 2022/5/9 10:30
 * @Version 1.0
 * 浅克隆：内存简单的copy
 */
@Data
public class ConcretePrototype implements Cloneable {

    private int age;
    private String name;
    private List<String> hobbies; // 引用类型，Cloneable的clone方法赋值的是引用类型的地址

    @Override
    public ConcretePrototype clone() {
        try {
            return (ConcretePrototype)super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }


}
